home *** CD-ROM | disk | FTP | other *** search
- Path: news.lpr.carel.fi!usenet
- From: Ari Lukumies <aril@cmt.lpr.mail.carel.fi>
- Newsgroups: comp.lang.c,comp.lang.c++,comp.lang.std.c,com[p.lang.std.c++
- Subject: Re: preprocessing question
- Date: Thu, 07 Mar 1996 16:56:03 +0200
- Organization: Carelcomp Forest
- Message-ID: <313EF903.1000@cmt.lpr.mail.carel.fi>
- References: <313b9e9f.480978@NEWS.CLOUD9.NET>
- NNTP-Posting-Host: renoir.cclahti.carel.fi
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (WinNT; I)
-
- John G. Alvord wrote:
- >
- > I have a couple compilers argument about the following problem:
- >
- > #define XXX (1)
- > #include <stdio.h>
- > int main(void)
- > {
- > #if XXX
- > printf("Hello World!");
- > #endif
- > return 0;
- > }
- >
- > most compilers I have tried preprocess the #if resulting in "#if (1)" and then
- > follow that instruction to generate the printf() call.
- >
- > One compiler (SAS/C 5.50 cross compiler on AIX for MVS) complains that the #if
- > line is an illegal constant. A close reading of the ANSI C standard document
- > reveals a clause that seems to imply (my reading) that a pre-processed series
- > of tokens that appear to be a preprocessing statement will be ignored. A
- > coworker who is more experienced then me feels that the #if does not fall
- > under that clause and the #if will be evaluated. His reasoning is that the
- > preprocessed series of tokens is just a part of a preprocessing statement.
- >
- > If someone can shed some light on this, he would make me very happy.
- >
- > Thanks!
- >
- > John Alvord
-
- Some (old?) preprocessors expect to find #xxx tokens starting at beginning of the
- line. Also, there may be preprocessors that would want "#if conditional". If this is
- the case, use
-
- #define XXX (1 == 1)
-
- or use the convention
-
- #define XXX
- ...
- #ifdef XXX
- ...
- #endif
-
- or, perhaps,
-
- #if defined XXX
- ...
- #endif
-
- HTH,
- AriL
- --
- All my opinions are mine and mine alone.
-